<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>泮河校区会议室预约系统</title>
    <meta name="keywords" content="H+后台主题,后台bootstrap框架,会员中心主题,后台HTML,响应式后台">
    <meta name="description" content="H+是一个完全响应式，基于Bootstrap3最新版本开发的扁平化主题，她采用了主流的左右两栏式布局，使用了Html5+CSS3等现代技术">

    <link rel="shortcut icon" href="favicon.ico">
    <link href="css/bootstrap.min.css-v=3.3.5.css"
          tppabs="http://www.zi-han.net/theme/hplus/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="css/font-awesome.min.css-v=4.4.0.css"
          tppabs="http://www.zi-han.net/theme/hplus/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="css/plugins/iCheck/custom.css"
          tppabs="http://www.zi-han.net/theme/hplus/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="css/animate.min.css" tppabs="http://www.zi-han.net/theme/hplus/css/animate.min.css"
          rel="stylesheet">
    <link href="css/style.min.css-v=4.0.0.css" tppabs="http://www.zi-han.net/theme/hplus/css/style.min.css?v=4.0.0"
          rel="stylesheet">
    <base target="_blank">
    <link rel="stylesheet" type="text/css" href="./layui/css/layui.css"/>
    <style>
        #zhuti{
            height:100%;
        }
        #zhuti::before{
            background:  url('img/logo1.png')  no-repeat fixed center;
            content:"";
            opacity:0.2;
            width:100%;
            height:100%;
            position:absolute;
        }
    </style>
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeInRight">

    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins" id="zhuti">
                <div class="ibox-title">
                    <h3 style="font-weight: 600;margin-top: 0;">添加申请</h3>
                </div>
                <div class="ibox-content">
                    <form method="post" id="bigform" autocomplete="off" class="form-horizontal">
                        <div class="form-group" style="margin-bottom: 0px;">
                            <label class="col-sm-2 control-label">会议室</label>
                            <!-- col-sm-4 m-l-n -->
                            <div class="col-sm-3">
                                <select class="form-control m-b" id="huoqumeeting" name="account">
                                    <!-- 会议室 -->
                                </select>
                            </div>
                            <label class="col-sm-2 control-label">会议名称</label>
                            <div class="col-sm-4">
                                <input type="text" name="meetingname" required placeholder="请输入会议名称"
                                       class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">会议内容</label>
                            <div class="col-sm-9">
                                <input type="text" name="meetingneirong" placeholder="请输入会议内容" class="form-control"
                                       required>
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group" id="laydate">
                            <label class="col-sm-2 control-label">开始时间</label>
                            <div class="col-sm-3">
                                <input type="text" name="starttime" required placeholder="yyyy-MM-dd HH:mm:ss"
                                       class="form-control"
                                       id="test1">
                            </div>

                            <label class="col-sm-2 control-label">结束时间</label>
                            <div class="col-sm-4">
                                <input type="text" name="endtime" required placeholder="yyyy-MM-dd HH:mm:ss"
                                       class="form-control"
                                       id="test2" disabled>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">参会人数</label>
                            <div class="col-sm-3">
                                <input type="number" name="people" min="0" required placeholder="请输入参会人数"
                                       class="form-control">
                            </div>
                            <label class="col-sm-2 control-label">茶杯数量</label>
                            <div class="col-sm-4">
                                <input type="number" name="teashu" min="0" required placeholder="请输入茶杯数量" class="form-control">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-2 control-label">无线会议话筒数量</label>
                            <div class="col-sm-3">
                                <input type="number" name="huatong" min="0" required placeholder="请输入无线会议话筒数量" class="form-control">
                            </div>
                            <label class="col-sm-2 control-label">无线手持话筒数量</label>
                            <div class="col-sm-4">
                                <input type="number" name="wireless" min="0" required placeholder="请输入无线手持话筒数量" class="form-control">
                            </div>

                        </div>
                        <!-- 	<div class="hr-line-dashed"></div> -->
                        <div class="form-group">
                            <label class="col-sm-2 control-label">拟会领导</label>
                            <div class="col-sm-3">
                                <input type="text" name="lingdao" required placeholder="请输入拟参会校领导" class="form-control">
                            </div>

                            <label class="col-sm-2 control-label">经办人</label>
                            <div class="col-sm-4">
                                <input type="text" name="jingbanren" required placeholder="请输入经办人" class="form-control">
                            </div>
                        </div>
                        <div class="hr-line-dashed"></div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">负责人</label>
                            <div class="col-sm-3">
                                <input type="text" name="fuzeren" required placeholder="请输入负责人" class="form-control">
                            </div>

                            <label class="col-sm-2 control-label">联系电话</label>
                            <div class="col-sm-4">
                                <input type="text" name="phoneid" required placeholder="请输入您的联系电话" class="form-control">
                            </div>
                        </div>

                        <div class="form-group layui-form"  >
                            <label class="col-sm-2 control-label">公安处备案</label>
                            <div class="col-sm-3">
<!--                                <input type="radio" name="gongan" value="true" title="是">-->
<!--                                <input type="radio" name="gongan" value="false" title="否" >-->
<!--                                   <input type="checkbox" name="yyy" lay-skin="switch" lay-text="ON|OFF" checked> -->
                                  <input type="checkbox" name="gongan" lay-skin="switch" lay-filter="switchTest1" required lay-text="是|否" class="form-control" checked>
                            </div>

                               <label class=" col-sm-2 control-label">学校疫情防控工作领导小组备案</label>
                               <div class="col-sm-4 " >
<!--                                   <input type="radio" name="control" value="true" title="是">-->
<!--                                   <input type="radio" name="control" value="false" title="否" >-->
                                  <input type="checkbox" class="form-control" name="control" required lay-skin="switch" lay-filter="switchTest2" lay-text="是|否" checked>

                               </div>
                        </div>
                        <div class="hr-line-dashed"></div>

                        <div class="form-group">
                            <div class="col-sm-3 col-sm-offset-4">
                                <input name="apply1" type="submit" style="margin-right: 20%;" id="tijiao" class="btn btn-primary"
                                       value="提交申请">
                                <input class="btn btn-white" id="reset1" type="reset" value="重新填写">
                            </div>
                        </div>
                    </form>
                </div>
                <script src="./layui/layui.js" type="text/javascript" charset="utf-8"></script>
                <script type="text/javascript">//----layui框架

                //获取时间
                function getNowTime(x) {
                    var myDate = new Date();
                    //获取当前年
                    var year = myDate.getFullYear();
                    //获取当前月
                    var month = myDate.getMonth() + 1;
                    //获取当前日
                    var date = myDate.getDate();
                    if (x == 1) {
                        date = date + 7;
                    }
                    var h = myDate.getHours(); //获取当前小时数(0-23)
                    var m = myDate.getMinutes(); //获取当前分钟数(0-59)
                    var s = myDate.getSeconds();
                    let now = year + '-' + p(month) + "-" + p(date) + " " + p(h) + ':' + p(m) + ":" + p(s);
                    return now;
                }

                function p(s) {
                    return s < 10 ? '0' + s : s;
                }

                <!--    拆分时间字符串-->
                function stringToTime(str) {
                    var date = str;
                    date = date.substring(0, 19);
                    date = date.replace(/-/g, '/');
                    date = date.replace(/:/g, '/');
                    date = date.replace(/\s/g, "/");
                    var a = date.split('/');
                    return a;
                };

                layui.use('laydate', function () {
                    var laydate = layui.laydate;
                    var nowTime = new Date();
                    var startTime = laydate.render({
                        elem: '#test1',
                        type: 'datetime',
                        btns: ['confirm'],
                        // min: 0,
                        // max: 100,
                        min: getNowTime(),
                        max: getNowTime(1),
                        done: function (value, date, endDate) {
                            //把结束时间的最小值改为开始时间
                            if(value != ''){
                                endTime.config.min = {
                                    year: date.year,
                                    month: date.month - 1,//关键
                                    date: date.date,
                                    hours: date.hours,
                                    minutes: date.minutes,
                                    seconds: date.seconds
                                };
                            }else{
                                endTime.config.min = {
                                    year: 2200,
                                    month: 0,//关键
                                    date: 1,
                                    // hours: date.hours,
                                    // minutes: date.minutes,
                                    // seconds: date.seconds
                                };
                            };


                            var id2 = parseInt($("option:selected").prop('id'));
                            var starttime = value;
                            let a=stringToTime(starttime);
                            // alert(a)
                            if(a[3]<8||a[3]>22){
                                $("#test1").val(123);
                                layer.alert('请选择8:00~22:00的时间');
                                // layer.alert("请注意会议时间：<br/>" +
                                //     "春秋冬：8:00~11:50   14:00~20:50 <br/>" +
                                //     "夏&nbsp;&nbsp;&nbsp;&nbsp;季：8:00~11:50   14:30~21:20 <br/>");
                                console.log($("#test1").val())
                                return
                            }

                            var endtime = $("input[name='endtime']").val();

                            let b=stringToTime(endtime);
                            // alert(b);
                            if(b[3]<8||b[3]>22){
                                $("#test2").val('123')
                                layer.alert('请选择8:00~10:00的时间');
                                // layer.alert("请注意会议时间：<br/>" +
                                //     "春秋冬：8:00~11:50   14:00~20:50 <br/>" +
                                //     "夏&nbsp;&nbsp;&nbsp;&nbsp;季：8:00~11:50   14:30~21:20 <br/>");
                                return
                            }

                            //8-22点
                            if(date.hours<8||date.hours>=22){
                              layer.alert("请注意会议时间，8:00-22:00");
                              //   layer.alert("请注意会议时间：<br/>" +
                              //       "春秋冬：8:00~11:50   14:00~20:50 <br/>" +
                              //       "夏&nbsp;&nbsp;&nbsp;&nbsp;季：8:00~11:50   14:30~21:20 <br/>");
                                $("input[name='starttime']").val('');
                            };
                            //监听huiyishijian
                            if (id2 != "" && starttime != ""&&date.hours>=8&&date.hours<=22) {
                                $("input[name='endtime']").removeAttr("disabled");
                                $.ajax({
                                    type: "POST",
                                    url: "/user/judgeStartTime",
                                    data: {
                                        "mid": id2,
                                        "starttime": starttime,
                                    },
                                    success: function (msg) {
                                        if (msg != ("true")) {
                                            // $.alert("温馨提示","时间冲突，请重新选择");
                                            layer.alert('时间冲突，请重新选择');
                                            $("input[name='starttime']").val("");
                                            $("input[name='endtime']").val("");
                                            $("input[name='endtime']").prop("disabled", true);
                                        }
                                        ;   // if(msg!=true){form.render();};
                                    },
                                    error: function (nn) {
                                        // $.alert("温馨提示","提交失败");
                                        layer.alert('提交失败');
                                    }
                                });
                            } else {
                                $("input[name='endtime']").prop("disabled", true);
                            }
                            ;//if结束
                        }//done结束
                    });

                    var endTime = laydate.render({
                        elem: '#test2',
                        type: 'datetime',
                        btns: ['now', 'confirm'],
                        min: 0,
                        max: 100,
                        done: function (value, date, endDate) {
                            //把开始时间的最大值改为结束时间的值
                            if(value != ''){
                                startTime.config.max = {
                                    year: date.year,
                                    month: date.month - 1,//关键
                                    date: date.date,
                                    hours: date.hours,
                                    minutes: date.minutes,
                                    seconds: date.seconds
                                };
                            }else{
                                startTime.config.max = {
                                    year: 2200,
                                    month: 0, //关键
                                    date: 1
                                }
                            };

                            //监听会议室时间是否冲涂，有借的吗
                            var id2 = parseInt($("option:selected").prop('id'));
                            var endtime = value;
                            var starttime = $("input[name='starttime']").val();
                            //
                            if(date.hours<=8||date.hours>=22){
                                layer.alert("请注意会议时间，8:00-22:00");
                                // layer.alert("请注意会议时间：<br/>" +
                                //     "春秋冬：8:00~11:50   14:00~20:50 <br/>" +
                                //     "夏&nbsp;&nbsp;&nbsp;&nbsp;季：8:00~11:50   14:30~21:20 <br/>");
                                $("input[name='endtime']").val("");
                            };
                            if (id2 != "" && starttime != "" && endtime != ""&&date.hours>=8&&date.hours<=22) {
                                $.ajax({
                                    type: "POST",
                                    url: "/user/judgeTime",
                                    data: {
                                        "mid": id2,
                                        "starttime": starttime,
                                        "endtime": endtime,
                                    },
                                    success: function (msg) {
                                        // form.render();
                                        if (msg != ("true")) {
                                            layer.alert('时间冲突，请重新选择');
                                            $("input[name='endtime']").val("");
                                            $("input[name='starttime']").val("");
                                            startTime.config.max = {
                                                year: date.year+1,
                                                month: date.month + 1,//关键
                                                date: date.date+30,
                                                hours: date.hours+24,
                                                minutes: date.minutes+60,
                                                seconds: date.seconds+10
                                            };
                                        } ;
                                    },
                                    error: function (nn) {
                                        layer.alert('提交失败');
                                    }
                                });
                            }
                            ;//if结束
                        }//done
                    });//test2
                });



                </script>
                <script src="js/jquery.min.js-v=2.1.4"
                        tppabs="http://www.zi-han.net/theme/hplus/js/jquery.min.js?v=2.1.4"></script>
                <script src="layui/layer/layer.js" type="text/javascript" charset="utf-8"></script>
                <script>//-----jquery框架-----
                $(document).ready(function () {
                    $(".i-checks").iCheck({
                        checkboxClass: "icheckbox_square-green",
                        radioClass: "iradio_square-green",
                    });
                    //----获取会议室---
                    $.ajax({
                        type: "POST",
                        url: "/user/getAllMeeting",
                        success: function (msg) {
                            var str = "";
                            for (let i = 0; i < msg.length; i++) {
                                str += "<option id=" + msg[i].id + ">" + msg[i].name + "</option>";
                            }
                            $("#huoqumeeting").append(str);
                        },
                        error: function (z) {
                            console.log(z);
                        }
                    });
                    //获取会议室信息
                    function getmeeting(id){
                     var mgh='';
                         $.ajax({
                            async:false,
                            type: "POST",
                            url: "/user/getAllMeeting",
                            data:{
                                "id":parseInt(id)
                            },
                            success:function(mgg){
                              mgh=mgg;
                            },
                            error:function(mg){
                                console.log(mg);
                            },
                        });
                     return mgh;
                    };


                    //人数
                    $("input[name='people']").on("input",function(){
                        var id2 = parseInt($("option:selected").prop('id'));
                        var gg=getmeeting();
                        var max=gg[id2-1].maxnum;
                        var xx=parseInt($("input[name='people']").val());
                        if(xx>max){
                            layer.alert("超出最大数量，请重新输入");
                            $("input[name='people']").val("");
                        }
                    });
                    //茶杯
                    $("input[name='teashu']").on("input",function(){
                        var id2 = parseInt($("option:selected").prop('id'));
                        var gg=getmeeting();
                        var max=gg[id2-1].teacup;
                        var xx=parseInt($("input[name='teashu']").val());
                        if(xx>max){
                            layer.alert("超出最大数量，请重新输入");
                            $("input[name='teashu']").val("");
                        }
                    });
                    //会议话筒
                    $("input[name='huatong']").on("input",function(){
                        var id2 = parseInt($("option:selected").prop('id'));
                        var gg=getmeeting();
                        var max=gg[id2-1].micro;
                        var xx=parseInt($("input[name='huatong']").val());
                        if(xx>max){
                            layer.alert("超出最大数量，请重新输入");
                            $("input[name='huationg']").val("");
                        }
                    });
                    //无线话筒
                    $("input[name='wireless']").on("input",function(){
                        var id2 = parseInt($("option:selected").prop('id'));
                        var gg=getmeeting();
                        var max=gg[id2-1].wireless;
                        var xx=parseInt($("input[name='wireless']").val());
                        if(xx>max){
                            layer.alert("超出最大数量，请重新输入");
                            $("input[name='wireless']").val("");
                        }
                    });

                    //监视会议室
                    $("#huoqumeeting").on('change', function () {
                        var id2 = parseInt($("option:selected").prop('id'));
                        var starttime = $("input[name='starttime']").val();
                        var endtime = $("input[name='endtime']").val();
                        if (id2 != "" && starttime != "" && endtime != "") {
                            $.ajax({
                                type: "POST",
                                url: "/user/judgeTime",
                                data: {
                                    "mid": id2,
                                    "starttime": starttime,
                                    "endtime": endtime,
                                },
                                success: function (msg) {
                                    if (msg != ("true")) {
                                        layer.alert("时间冲突，请重新选择");
                                        $("input[name='starttime']").val("");
                                        $("input[name='endtime']").val("");
                                        $("input[name='endtime']").prop("disabled", true);
                                    }
                                    ;
                                },
                                error: function (nn) {
                                    layer.alert("温馨提示", "提交失败");
                                }
                            });
                        } else {//选了开始时间，改了会议室
                            if (id2 != "" && starttime != "") {
                                $.ajax({
                                    type: "POST",
                                    url: "/user/judgeStartTime",
                                    data: {
                                        "mid": id2,
                                        "starttime": starttime,
                                    },
                                    success: function (msg) {
                                        if (msg != ("true")) {
                                            layer.alert("时间冲突，请重新选择");
                                            $("input[name='starttime']").val("");
                                            $("input[name='endtime']").val("");
                                            $("input[name='endtime']").prop("disabled", true);
                                        }
                                    },
                                    error: function (nn) {
                                        layer.alert("提交失败");
                                    }
                                });
                            }
                        }//else结束
                    });
                    // 监听是否
                    layui.use('form', function(){
                        var form = layui.form;
                        //公安
                        form.on('switch(switchTest1)', function(data){
                            console.log(data.elem.checked);
                            var ll= layui.$("input[name='control']").is(':checked');
                            // layui.$(test).is(':checked');
                            if( data.elem.checked==false&&$.trim(ll)==$.trim('true')){
                                layer.tips('温馨提示：没有备案，无法申请', data.othis);
                                $("input[name='apply1']").prop("disabled", true);
                            }else if(data.elem.checked==true&&$.trim(ll)==$.trim('true')){
                                $("input[name='apply1']").prop("disabled", false);//关闭属性
                            }else if(data.elem.checked==false&&$.trim(ll)==$.trim('false')){
                                layer.tips('温馨提示：没有备案，无法申请', data.othis);
                                $("input[name='apply1']").prop("disabled", true);
                            }else{
                                $("input[name='apply1']").prop("disabled", true);
                            };
                        });
                        //疫情办公室
                        form.on('switch(switchTest2)', function(data){
                            var ll= layui.$("input[name='gongan']").is(':checked');
                            if( data.elem.checked==false&&$.trim(ll)==$.trim('true')){
                                layer.tips('温馨提示：没有备案，无法申请', data.othis);
                                $("input[name='apply1']").prop("disabled", true);
                            }else if( data.elem.checked==true&&$.trim(ll)==$.trim('true')){
                                $("input[name='apply1']").prop("disabled", false);//关闭属性
                            }else if( data.elem.checked==false&&$.trim(ll)==$.trim('false')){
                                layer.tips('温馨提示：没有备案，无法申请', data.othis);
                                $("input[name='apply1']").prop("disabled",true);
                            }else{
                                $("input[name='apply1']").prop("disabled",true);
                            };
                        });
                    });

                   //提交
                    $("#bigform").on("submit", function () {
                        var huoquid = $("option:selected").text();
                        var id2 = $("option:selected").prop('id');
                        var meetingname = $("input[name='meetingname']").val();
                        var meetingneirong = $("input[name='meetingneirong']").val();
                        var starttime = $("input[name='starttime']").val();
                        var endtime = $("input[name='endtime']").val();
                        var people = $("input[name='people']").val();
                        var huatong=  $("input[name='huatong']").val();
                        var wireless= $("input[name='wireless']").val();
                        var teashu = $("input[name='teashu']").val();
                        var lingdao = $("input[name='lingdao']").val();
                        var jingbanren = $("input[name='jingbanren']").val();
                        var fuzeren = $("input[name='fuzeren']").val();
                        var phoneid = $("input[name='phoneid']").val();
                        var control= layui.$("input[name='control']").is(':checked');
                        var gongan= layui.$("input[name='gongan']").is(':checked');
                        // let gongan = $("input[name='gongan']:checked").val();
                        // let control= $("input[name='control']:checked").val();
                      //  console.log("==="+control+"==="+gongan)
                        if($.trim(control)==$.trim("true") && $.trim(gongan)==$.trim("true") ){
                            $.ajax({
                                type: "POST",
                                url: "/user/submit",
                                data: {
                                    "account": id2,
                                    "meetingname": meetingname,
                                    "meetingneirong": meetingneirong,
                                    "starttime": starttime,
                                    "endtime": endtime,
                                    "people": people,
                                    "huatong":huatong,
                                    "wireless":wireless,
                                    "teashu": teashu,
                                    "lingdao": lingdao,
                                    "jingbanren": jingbanren,
                                    "fuzeren": fuzeren,
                                    "phoneid": phoneid,
                                    "gongan": "是",
                                    "control":"是"
                                },
                                success: function (msg) {
                                    layer.alert("提交成功");
                                    $("input[name='meetingname']").val("");
                                    $("input[name='meetingneirong']").val("");
                                    $("input[name='starttime']").val("");
                                    $("input[name='endtime']").val("");
                                    $("input[name='people']").val("");
                                    $("input[name='huatong']").val("");
                                    $("input[name='wireless']").val("");
                                    $("input[name='teashu']").val("");
                                    $("input[name='lingdao']").val("");
                                    $("input[name='jingbanren']").val("");
                                    $("input[name='fuzeren']").val("");
                                    $("input[name='phoneid']").val("");
                                    $("input[name='gongan']").val("");
                                },
                                error: function (nn) {
                                    layer.alert("提交失败");
                                    console.log(nn);
                                },
                            });
                            return false;
                        }else{
                            layer.alert("请先备案");
                        };//if结束

                    });
                    //----结束---
                });
                </script>
                <script src="js/bootstrap.min.js-v=3.3.5"
                        tppabs="http://www.zi-han.net/theme/hplus/js/bootstrap.min.js?v=3.3.5"></script>
                <script src="js/content.min.js-v=1.0.0"
                        tppabs="http://www.zi-han.net/theme/hplus/js/content.min.js?v=1.0.0"></script>
                <script src="js/plugins/iCheck/icheck.min.js"
                        tppabs="http://www.zi-han.net/theme/hplus/js/plugins/iCheck/icheck.min.js"></script>

                <script type="text/javascript" src="../../../tajs.qq.com/stats-sId=9051096"
                        tppabs="http://tajs.qq.com/stats?sId=9051096" charset="UTF-8"></script>
</body>

</html>
